package com.springboot.cloud.demos.ribbon.rest;

import com.springboot.cloud.common.core.entity.vo.Result;
import com.springboot.cloud.demos.entity.form.AddressInfoForm;
import com.springboot.cloud.demos.entity.param.AddressInfoQueryParam;
import com.springboot.cloud.demos.ribbon.service.AddressInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
public class AddressInfoController {

    @Autowired
    private AddressInfoService addressInfoService;

    @PostMapping("/addressInfo/conditions")
    public Result conditions(@RequestBody AddressInfoQueryParam params) {
        return addressInfoService.conditions(params);
    }

    @PostMapping("/addressInfo")
    public Result add(@RequestBody AddressInfoForm addressInfoForm) {
        return addressInfoService.save(addressInfoForm);
    }

    @PutMapping(value = "/addressInfo")
    public Result update(@RequestBody AddressInfoForm addressInfo) {
        return addressInfoService.update(addressInfo);
    }

    @GetMapping("/addressInfo/{id}")
    public Result get(@PathVariable(value = "id") String id) {
        return addressInfoService.addressInfo(id);
    }

    @DeleteMapping("/addressInfo/{id}")
    public void delete(@PathVariable(value = "id") String id) {
        addressInfoService.delete(id);
    }

}
